/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.ce.entitybeans.currency;

import com.bionic.ce.entities.Currency;
import com.bionic.ce.entities.User;
import com.bionic.ce.entitybeans.AbstractFacade;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

/**
 *
 * @author Jarik
 */
@Stateless
public class CurrencyFacade extends AbstractFacade<Currency> implements CurrencyFacadeLocal {
    @PersistenceContext(unitName = "Currency_ExchangeEE-PU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CurrencyFacade() {
        super(Currency.class);
    }
    
    public Currency findByShortName(String currencyShortName){
        TypedQuery<Currency> query = em.createNamedQuery("Currency.findByShortName", Currency.class);
        query.setParameter("shortName", currencyShortName);
        Currency currency = null;
        try{
            currency = query.getSingleResult();
        }catch(NoResultException e){
            e.printStackTrace();
        }
        return currency;
    }
    
}
